package com.heima.media.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.media.dto.ChannelDto;
import com.heima.media.entily.WmChannel;
import com.heima.media.entily.WmUser;
import com.heima.media.service.IWmChannelService;

import com.heima.media.service.IWmUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @BelongsProject: heima-leadnews
 * @BelongsPackage: com.itheima.media.controller
 * @Author:
 * @CreateTime: 2022-06-25  16:18
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/api/v1/channel")
@Api(tags = "自媒体用户信息表接口")
@CrossOrigin
public class WmChannelController {
    @Autowired
    private IWmChannelService wmChannelService;

    /**
     * @description: 根据查询分页列表
     * @author: wangjian
            * @date: 2022/6/25 18:29
 * @param: channelDto
 * @return: com.heima.common.dto.ResponseResult
     **/
    @ApiOperation(value = "pageList",notes = "根据查询分页列表")
    @ApiImplicitParam(value = "分页参数以及名称",paramType = "dto",dataType = "ChannelDto",name = "dto")
    @PostMapping("/list")
    public ResponseResult pageList(@RequestBody ChannelDto channelDto){
        return   wmChannelService.pageList(channelDto);
    }
    /**
     * @description: 保存频道
     * @author: wangjian
            * @date: 2022/6/25 18:29
     * @param: entity
     * @return: com.heima.common.dto.ResponseResult
     **/
    @ApiOperation(value = "saveChannel",notes = "保存频道")
    @ApiImplicitParam(value = "保存频道的实体类",paramType = "entity",dataType = "WmChannel",name = "entit")
    @PostMapping
    public ResponseResult saveChannel(@RequestBody WmChannel entity){
        return wmChannelService.saveChannel(entity);
    }
/**
 * @description: 查询所有的频道
 * @author: wangjian
        * @date: 2022/7/1 20:17
 * @return: com.heima.common.dto.ResponseResult
 **/
    @GetMapping("/channels")
    public ResponseResult channels() {
        List<WmChannel> list = wmChannelService.list();
        return ResponseResult.okResult(list);
    }
}
